package com.region.http.client.plugins;

import com.region.common.utils.RandomUtils;
import com.region.http.client.common.RegionContextHolder;
import com.region.plugin.Interceptor;
import com.region.plugin.ProceedPoint;

/**
 * @author 26225
 * @date 2023/9/2 20:16
 * @description
 */
public class RequestHeaderInterceptor implements Interceptor {

    @Override
    public void doBefore() {
        RegionContextHolder.setHeader("token", RandomUtils.getRandomString(48));
    }

    @Override
    public void doAfter() {
        RegionContextHolder.remove();
    }

    @Override
    public void doAfterThrowing(Throwable throwable) throws Throwable {
        throw  throwable;
    }

    @Override
    public Object proceed(ProceedPoint proceed) throws Throwable {
        System.out.println("执行前打印");
        Object data = proceed.proceed();
        System.out.println("执行后打印");
        return data;
    }

    @Override
    public int order() {
        return 10;
    }
}
